import React from "react"
import classnames from 'classnames' 
import "./index.css"
import Proptypes from 'prop-types'
import { connect } from 'react-redux'
import { setLoading } from '../../actions/newsListActionCreator'


function ListItem(props) {
	return (
		<li className={classnames("list-item")}>
			<h3>{props.title}</h3>
			<p>{props.text}</p>
		</li>
	)
}

ListItem.propTypes = {
	title:Proptypes.string.isRequired,
	text:Proptypes.string.isRequired
}
ListItem.defaultProps = {
	title:"我是ListItem默认title",
	text:"我是ListItem默认text"
}

const getStateFromProps = (state)=>{
	return {
		isLoading:state.newsList.isLoading
	}
}
const getDispatchFromProps = (dispatch)=>{
	return {
		openLoading:flag=>dispatch(setLoading(flag))
	}
}

const getMemoProps = (...arg)=>{
	console.log(arg)
}
export default connect(getStateFromProps,getDispatchFromProps)(React.memo(ListItem,getMemoProps))